#include <stdio.h>

int main() {
    int n,in,a,b;
    scanf("%d",&n);
    int sum[n+1];
    sum[0]=0;
    for(int i=0;i<n;i++) {
        scanf("%d",&in);
        sum[i+1]=sum[i]+in;
    }
    while(scanf("%d %d",&a,&b)!=EOF) {
        printf("%d\n",sum[b+1]-sum[a]);
    }
    return 0;
}